/*
 * Copyright (c) 2024 iSOFT INFRASTRUCTURE SOFTWARE CO., LTD.
 * easyAda is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */

#ifndef __UAPI_ADDRSPACE_H__
#define __UAPI_ADDRSPACE_H__

enum MAP_ATTRS {
    MAP_AP_KRW_UNA = 0x0,
    MAP_AP_KRW_URW = 0x1,
    MAP_AP_KRO_UNA = 0x2,
    MAP_AP_KRO_URO = 0x3,
    MAP_AP_COUNT,
    MAP_AP_MASK = 0x0000f,

    MAP_TYPE_MASK   = 0x000f0,
    MAP_TYPE_DEVICE = 0x10,
    MAP_TYPE_RAM    = 0x20,

    MAP_FLAG_NONE       = 0x0000,
    MAP_FLAG_EXECUTABLE = 0x0100,
    MAP_FLAG_CACHEABLE  = 0x0200,
    MAP_FLAG_SHAREABLE  = 0x0400,
    MAP_FLAG_GLOBAL     = 0x0800,

    MAP_LEVEL_MASK = 0XF000,
    MAP_LEVEL_EL0  = 0X1000,
    MAP_LEVEL_EL1  = 0X2000,
    MAP_LEVEL_EL2  = 0X3000,
    MAP_LEVEL_EL3  = 0X4000,

    MAP_PTL_MASK  = 0xf0000,
    MAP_PTL_PAGES = 0x00000,
    MAP_PTL_L1    = 0x10000,
    MAP_PTL_L2    = 0x20000,
    MAP_PTL_L3    = 0x30000,
    MAP_PTL_L4    = 0x40000,
};

static inline unsigned int map_mk_attr(unsigned level, unsigned type, unsigned Access_flag, unsigned extra)
{
    return level | type | Access_flag | extra;
}

#endif
